package com.jiuyun.servlet;

import com.jiuyun.dao.ExamDao;
import com.jiuyun.dao.QuestionDao;
import com.jiuyun.dao.impi.ExamDaoImpl;
import com.jiuyun.dao.impi.ExamDaoImpl;
import com.jiuyun.dao.impi.QuestionDaoImpi;
import com.jiuyun.entity.Exam;
import com.jiuyun.entity.Exam1;
import com.jiuyun.entity.Question;
import com.jiuyun.entity.Question1;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet("/Exam/*")
public class ExamServlet1 extends BaseServlet {
        ExamDao dao=new ExamDaoImpl();
        QuestionDao questionDao = new QuestionDaoImpi();

    protected void find(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException {
        System.out.println("考试信息");
        String exam_id=request.getParameter("exam_id");
        List<Exam1> list=dao.examfind(exam_id);
        Exam1 exam = dao.find(exam_id);
        List<Question1> questionlist = questionDao.find(exam.getExam_code());
        System.out.println(list);
        HttpSession session=request.getSession();
        session.setAttribute("examlist",list);
        session.setAttribute("length", questionlist.size());
        response.sendRedirect("/Eventstar/answer.jsp");
    }

    protected  void find1(HttpServletRequest request,HttpServletResponse response) throws  ServletException,IOException,SQLException{
        System.out.println("考试信息1");
        String exam_id=request.getParameter("exam_id");
        List<Exam1> list=dao.examfind(exam_id);
        HttpSession session=request.getSession();
        System.out.println(list);
        session.setAttribute("exam1list",list);
        response.sendRedirect("/Eventstar/answer_sheet.jsp");
    }


}
